﻿FlyTalk.views.TalkView = Ext.extend(Ext.TabPanel, {
	id: 'talkView',
	indicator: true,
    fullscreen: true,
    layout: 'card',  
    
    tabBar:{
        dock: 'bottom', // will put the menu on the bottom of the screen
        layout:{
            pack: 'center' // this will center the menu
        },
    },
    
    initComponent: function () {
    	
    	Ext.apply(FlyTalk.views, {
			ColumnView: new FlyTalk.views.ColumnView(),
			ColumnView1: new FlyTalk.views.ColumnView(),
			ColumnView2: new FlyTalk.views.ColumnView(),
			HelpView: new FlyTalk.views.HelpView(),
			//SearchResultsView: new FlyTalk.views.SearchResultsView(),
			//SearchView: new FlyTalk.views.SearchView(),
        });
    	
    	// back button on toolbar
		this.backButton = new Ext.Button({
			iconCls: 'home',
			iconMask: true,
			handler: this.backButtonTap,
			scope: this
		});
    	
    	// tool bar
		this.composeButton = new Ext.Button({
            iconCls: 'add',
			iconMask: true,
            handler: this.onCompose,
            scope: this
        });
		
			// Tweet toolbar
		this.tweetToolbar = new Ext.Toolbar({
			id: 'tweetToolbar',
			title: 'Talk',
			doc: 'top',
			layout: 'hbox',
			items: [
			    this.backButton,
				{xtype: 'spacer'},
  				 this.composeButton,
			]
		});

        this.dockedItems = [this.tweetToolbar];
  		
  		this.items = [
  		              FlyTalk.views.ColumnView, 
  		              FlyTalk.views.ColumnView1, 
  		              FlyTalk.views.ColumnView2, 
  		              FlyTalk.views.HelpView,];

        FlyTalk.views.TalkView.superclass.initComponent.call(this);
    },
    
    onCompose: function (record, index) {
    	
    	if(this.tweetToolbar.title == 'Bored'){
	        Ext.dispatch({
	            controller: FlyTalk.controllers.ftController,
	            action: 'openPlusSuggest',
	        });
    	}else{
    		Ext.dispatch({
	            controller: FlyTalk.controllers.ftController,
	            action: 'openPlus',
	        });
    	}
    },
    
    backButtonTap: function () {
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openHome'
        });
    },
});